package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {
    @Select("select count(0) from dish where category_id=#{categoryId}")
    int getCountByCategory(Long categoryId);

    //新增菜品
    @AutoFill(value = OperationType.INSERT)
    void add(Dish dish);

    Page<DishVO> query(DishPageQueryDTO queryDTO);
    //批量删除
    void del(List<Long> ids);

    @Select("select status from dish where id=#{id}")
    int getStatusById(Long id);

    //根据id查询启售的菜品
    @Select("select * from dish where id=#{id} and status=1")
    DishVO getById(Long id);


    @AutoFill(value = OperationType.UPDATE)
    void update(Dish dish);

    @Select("select * from dish where category_id=#{categoryId}")
    List<Dish> listByCatehoryId(Long categoryId);

    List<Dish> list(Dish dish);

    @Select("select category_id from dish where id=#{id}")
    long getCategoryById(Long id);

    @Select("select count(*) from dish where status=#{status}")
    Integer getIsOrNotSoldCount(int i);
}
